﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufUiCommonDef.h"

namespace gnuf {

    struct Planet
    {
        int x, y, width, height; // Geometry
        Planet() : x(0), y(0), width(0), height(0) {}
        void reset() { this->x = this->y = this->width = this->height = 0; }
        int    top() const { return this->y; }
        int  right() const { return this->x + this->width; }
        int bottom() const { return this->y + this->height; }
        int   left() const { return this->x; }
        bool empty() const {
            return (this->width < 1 || this->height < 1);
        }
    };

    struct ItemPositionContext
    {
        Planet Base;
        EPlacement Placement = eAtTheBottom;
        int ItemWidth = 0;
        int ItemHeight = 0;
    };

    class GNUF_BASE_EXPORT ItemPositionCalculator
    {
    public:
        ItemPositionCalculator(ItemPositionContext& context);
        ~ItemPositionCalculator() {}

        void calculate(int& posX, int& posY);
    private:
        ItemPositionContext& m_context;
    };
}
